1 Public Class FrmSysUser
2
3     Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
4         Me.Close()
5     End Sub
6
7     Private Sub FrmSysUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
8         If UCase(xUser_Access) = UCase(
"Administrator") Then
9             FillListView(ExecuteSQLQuery(
"select user_id as 'Account No', Username as 'Username', Access_type as 'Access Type' FROM tbl_users ORDER BY Username"), lstusers, 1)
10             Me.lstusers.Focus()
11             Me.lstusers.Select()
12         Else
13             Me.Close()
14             frmadduser.Text =
"Edit User Account"
15             frmadduser.ShowDialog()
16         End If
17     End Sub
18
19     Private Sub cmdadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd.Click
20         frmadduser.Text =
"Add User Account"
21         frmadduser.txtlname.Text =
""
22         frmadduser.txtfname.Text =
""
23         frmadduser.txtmname.Text =
""
24         frmadduser.txtaddress.Text =
""
25         frmadduser.txtcontact.Text =
""
26         frmadduser.txtusername.Text =
""
27         frmadduser.txtpassword.Text =
""
28         frmadduser.txtconfirm.Text =
""
29         frmadduser.ShowDialog()
30     End Sub
31
32     Private Sub cmdremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdremove.Click
33         If MsgBox(
"Do you want to delete this profile?", MsgBoxStyle.YesNo, "Sales And Inventory") = MsgBoxResult.Yes Then
34             lstusers.Focus()
35             lstusers.Select()
36             If xUser_ID = lstusers.FocusedItem.Text Then
37                 MsgBox(
"You can't delete your own user account !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
38                 Exit Sub
39             Else
40                 sqlSTR =
"DELETE FROM tbl_users WHERE user_ID =" & lstusers.FocusedItem.Text
41                 ExecuteSQLQuery(sqlSTR)
42                 FillListView(ExecuteSQLQuery(
"select user_id as 'Account No', Username as 'Username', Access_type as 'Access Type' FROM tbl_users"), lstusers, 1)
43             End If
44             
'MsgBox(lstusers.FocusedItem.Text)
45         End If
46     End Sub
47
48     Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
49         
'MsgBox(lstusers.FocusedItem.Text)
50         frmadduser.Text =
"Edit User Account"
51         frmadduser.ShowDialog()
52     End Sub
53
54     Private Sub cmdsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsearch.Click
55         
'sqlSTR =
56         
' MsgBox(sqlSTR)
57         FillListView(ExecuteSQLQuery(
"SELECT user_id as 'Account No', username as 'Username', access_type as 'Access Type' FROM tbl_users WHERE username LIKE '" & Replace(txtsearch.Text, "'", "'") & "%' ORDER BY username"), lstusers, 1)
58     End Sub
59 End Class


Gõ tìm kiếm nhanh...